pub fn odd_fibnacci_sum(threshold: u32) -> u32 {
    Fibnacci(1, 1)
        .take_while(|&x| x < threshold)
        .filter(|&x| x % 2 == 1)
        .sum()
}

struct Fibnacci(u32, u32);

impl Iterator for Fibnacci {
    type Item = u32;

    fn next(&mut self) -> Option<Self::Item> {
        let Fibnacci(a, b) = *self;
        *self = Fibnacci(b, a + b);
        Some(a)
    }
}
